package fonline2.utils

import io.Source
import util.matching.Regex
import java.io.{FileWriter, File}

/**
 * User: wladimiiir
 * Date: 12/20/12
 * Time: 6:56 PM
 */
object MapSceneryScriptGenerator {
  def main(args: Array[String]) {

    val sceneryPids = Array(2005, 2274, 2257, 2106, 4608, 4601, 4602, 2252)
    val serverPath = "/home/wladimiiir/-development/fonline2/testserver/current/Server/"

    for (cityNum <- Range(2, 16)) {
      val file = new File(serverPath + "maps/e_city" + cityNum + ".fomap")
      var map = Source.fromFile(file).getLines().mkString("\n")
      for (sceneryPid <- sceneryPids) {
        map = map.replaceAll("ProtoId\\s*" + sceneryPid + "\\s*MapX\\s*\\d*\\s*MapY\\s*\\d*", "$0\n" +
                "ScriptName           resources\nFuncName             _ScavengeSourceInit")
      }

      val writer = new FileWriter(file)
      writer.write(map)
      writer.close()
    }
  }
}
